package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mapper.PermissionMapper;
import com.example.model.PermissionDO;
import com.example.service.PermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public Map<String, String> getPermissionMap() {
        List<PermissionDO> list = permissionMapper.selectList(new QueryWrapper<PermissionDO>());
        Map<String, String> map = new HashMap<>();

        list.stream().forEach(item -> {
            map.put(item.getPath(), item.getRole());
        });

        return map;
    }
}
